let BASE_URL = 'http://demonuxtapi.dishait.cn/mobile/' //线上地址
// 2
const http = (options = {}) => {

	return new Promise((reslove, reject) => {
		//loading条
		uni.hideLoading({
			title: "正在加载中..."
		})
	
		uni.request({
		
			url: BASE_URL + options.url,
			method: options.method || 'GET',
			data: options.data || {},
			timeout: 8000, //8秒超时间，单位ms
			header:{
				"appid":"bd9d01ecc75dbbaaefce",
				"token":uni.getStorageSync("token")
			},
			//添加响应头
			success: (res) => {
				reslove(res.data)
			},
			fail: (err) => {
				uni.showToast({
					title: "请求接口失败",
					duration: 1500,
					mask: false
				})
				reject(err)
			},
			complete: (response) => {
				setTimeout(() => {
					uni.hideLoading()
				}, 1000)
			}
		})
	})
}


// 导出
export default http